<template>
  <div class="alone-outBox f14">
    <div class="alone-topBox mb16">
      <div class="flex flex-warp flex_bt">
        <div class="flex flex-warp" style="align-items:center">
          <div class="mb16">
            <span>专家姓名：</span>
            <el-input
              v-model="searchObj.ifName"
              placeholder="请输入专家姓名"
              class="width200 mr16"
              clearable
            />
          </div>
          <div class="mb16 mr16">
            <span>单位名称：</span>
            <el-input
              v-model="searchObj.ifCompany"
              placeholder="请输入单位名称"
              class="width200 mr16"
              clearable
            />
          </div>
          <div class="mb16 mr16">
            <span>所属行业：</span>
            <el-select
              v-model="searchObj.fdId1"
              placeholder="请选择"
              class="width200"
              clearable
            >
              <el-option
                v-for="item in industryTypeList"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </div>
          <div class="mb20">
            <el-button @click="React">重置</el-button>
            <el-button type="primary" @click="SearchListBt">筛选</el-button>
          </div>

        </div>

        <div class="realitive">
              <el-button type="primary" icon="el-icon-plus" class="add_zj" @click="$router.push('/specialist/add')">新增专家</el-button>
          </div>
      </div>
    </div>

    <div class="tableBox">
      <!-- 表格 -->
      <el-table
        v-loading="loading"
        :data="DataTable"
        style="width: 100%"
        max-height="620"
      >
        <el-table-column
          prop="insCount"
          label="专家姓名"
          min-width="100"
          align="left"
        >
        <template slot-scope="scope">
          {{scope.row.ifName}}
        </template>
        </el-table-column>
        <el-table-column prop="download" label="手机号"  min-width="150" align="left" >
          <template slot-scope="scope">
            {{scope.row.ifMobile}}
          </template>
        </el-table-column>

        <el-table-column
            prop="date"
            label="所属行业"
            min-width="200"
            align="left"
        >
          <template slot-scope="scope">
            {{scope.row.ifSpecializefield1}}
          </template>
        </el-table-column>
        <el-table-column
          prop="date"
          label="单位名称"
          min-width="200"
          align="left"
        >
          <template slot-scope="scope">
            {{scope.row.ifCompany}}
          </template>
        </el-table-column>
        <el-table-column
          prop="date"
          label="录入时间"
          min-width="150"
          align="left">
        <template slot-scope="scope">
          {{scope.row.createTime}}
        </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="200" fixed="right">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="editAuthor(scope.row)"
            >修改</el-button>
            <el-button
              type="text"
              @click="deleted(scope.row)"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="alignRight">
        <Pagination
          :total="total"
          :page="searchObj.page"
          :limit="searchObj.limit"
          @pagination="paginations"
        />
      </div>
    </div>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination/index.vue'
import Cookies from 'js-cookie'
import indexapi from '@/api/index'
export default {
  components: {
    Pagination
  },
  data () {
    return {
      DataTable: [],
      searchObj: {
        imshowid: Cookies.get('imShowId')
          ? Cookies.get('imShowId')
          : '',
        limit: 10,
        page: 1,
        fdId1: '',
        ifName: '',
        ifCompany: ''
      },
      total: 0,
      loading: false,
      reasonDia: false,
      returnReason: '',
      industryTypeList: []
    }
  },
  mounted () {
    this.getTypeList()
    this.SearchList()
  },
  methods: {
    // 删除
    deleted (val) {
      this.$confirm('此操作将永久删除该专家, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          const form = {
            id: val.authorID,
            imshowid: Cookies.get('imShowId')
              ? Cookies.get('imShowId')
              : ''
          }
          indexapi.specialist.deleted(form).then((res) => {
            if (res.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              })
              this.SearchList()
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 编辑
    editAuthor (val) {
      this.$router.push({ path: '/specialist/add', query: { id: val.authorID, imshowId: val.adminID } })
    },
    getTypeList () {
      indexapi.support.getIndustryClassifySelectByLevel().then((res) => { // 获取行业分类
        if (res.code == 200) {
          this.industryTypeList = res.data.data
        }
      })
    },
    // 重置
    React () {
      this.searchObj = {
        imshowid: Cookies.get('imShowId')
          ? Cookies.get('imShowId')
          : '',
        keyWords: '',
        status: '',
        limit: 10,
        page: 1,
        recommend: null
      }
      this.datatime = []
      this.SearchList()
    },
    // 查询
    SearchListBt () {
      this.searchObj.limit = 10
      this.searchObj.page = 1
      this.SearchList()
    },
    SearchList () {
      this.loading = true
      indexapi.specialist.selectAuthorList(this.searchObj).then((res) => {
        this.loading = false
        this.DataTable = res.data.records
        this.total = res.data.total
      })
    },
    // 分页
    paginations (val) {
      this.searchObj.limit = val.limit
      this.searchObj.page = val.page
      this.SearchList()
    },
    releaseInformation () {
      this.$router.push('/content/solutionscheme/solution/addoredit')
    }
  }
}
</script>
<style scoped>
.topButton {
  position: absolute;
  right: 20px;
  top: 16px;
}
.flex_bt {
  justify-content: space-between;
}
.icon_right {
  font-weight: 600;
  color: #0c7ff2;
  cursor: pointer;
  font-size: 18px;
}
.add_zj{
  position: absolute;
  top: 0px;
  right: 0px;
}
</style>
